// some core algorithm such as binary tree
#![allow(dead_code)]

struct Node {
    data: i32,
    left: Option<Box<Node>>,
    right: Option<Box<Node>>,
}

fn inorder_dfs(node: &Option<Box<Node>>) {
    if let Some(n) = node {
        inorder_dfs(&n.left);
        println!("{}", &n.data);
        inorder_dfs(&n.right);
    }
}

fn flip_tree(node: &mut Option<Box<Node>>) {
    // flip the tree
    if let Some(n) = node {
        let tmp = n.left.take();
        n.left = n.right.take();
        n.right = tmp;

        flip_tree(&mut n.left);
        flip_tree(&mut n.right);
    }
}
